package com.globagames.strategicgames.model
{
	import mx.collections.ArrayCollection;

	[Managed]
	[RemoteClass(alias="com.globagames.dogs.model.Company")]
	public class Company
	{
		
		public var companyId:int = -1;
		public var name:String;
		public var soldiers:ArrayCollection;
		public var factionCode:String;
		
		public var renown:int = 125;
		public var resource:int = 50;
		public var value:int = 0;
		
		public static var identifierCounter:int = 0;

		public var captain:Soldier;
		public function Company()
		{
			soldiers = new ArrayCollection();
		}
		public function getSoldier(identifier:String):Soldier {
			for(var i:int = 0; i < soldiers.length;i++) {
				var s:Soldier = soldiers.getItemAt(i) as Soldier;
				if( s.soldierIso.identifier == identifier) return s;
			}
			return null;
		}
		public function clone():Company {
			var c:Company = new Company();
			c.companyId = companyId;
			c.name = name;
			for(var i:int = 0 ; i < soldiers.length ; i++ ) {
				c.soldiers.addItem(Soldier(soldiers.getItemAt(i)).clone());
			}
			c.factionCode = factionCode;
			c.renown = renown;
			c.resource = resource;
			c.value = value;
			return c;
		}

	}
}